package scene.composants.popupmenu;

import java.awt.event.*;

import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;

import yaut.ENV;



public class SceneJPopupMenu extends JPopupMenu implements ActionListener, FocusListener
{
	private static final long serialVersionUID = 1L;
	
	private JMenuItem itemAligner, itemReorganiser;

	public SceneJPopupMenu()
	{
		//Creation du sous menu Aligner les classes
		itemAligner = new JMenuItem("Aligner les composants");
		this.add(itemAligner);	
		itemAligner.addActionListener(this);
		
		itemReorganiser = new JMenuItem("Reorganiser les composants");
		this.add(itemReorganiser);	
		itemReorganiser.addActionListener(this);

		this.setVisible(false);
		
	}
	
	public void actionPerformed(ActionEvent e)
    {
		if(e.getActionCommand()=="Aligner les composants")
    	{
    		ENV.FRAME.getControleur().getScene().alignerComposantsScene();
    		this.setVisible(false);
    	}
		
		if(e.getActionCommand()=="Reorganiser les composants")
    	{
    		ENV.FRAME.getControleur().getScene().reorganiserComposantsScene();
    		this.setVisible(false);
    	}
    }

	public void focusGained(FocusEvent fe)
	{
		this.repaint();
	}

	public void focusLost(FocusEvent fe)
	{
		this.setVisible(false);
	}
}
